<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
   //通过 for in 把 值加在一起，并添加all这个属性上
 
    // var obj = {
    //     a: 1,
    //     b: 2,
    //     c: 4
    // };
      
    // console.log(obj.all) -> 7    // 最终输出


    var obj = {
        a: 1,
        b: 2,
        c: 8
    };
    let all = 0;
    for(let attr in obj){
         all += obj[attr];
    }
    
    obj.all = all;

    console.log(obj)
    
    


</script>
</html>